﻿#pragma once

#include <QGraphicsView>
#include <MinimapContainterWidget.h>

class GraphicsScene;

class GraphicsView : public QGraphicsView
{
	Q_OBJECT
public:
	GraphicsView(QWidget* parent = nullptr);
	~GraphicsView();
	void init();
	void createMinimap();
	GraphicsScene* getScene();
	void setOriginImageVisable(bool isVisable);
	// 获取视图的缩放比例
	qreal getViewScale();
	// 获取中心item的缩放比例
	qreal getItemScale();
	// 设置中心item的缩放比例
	void setItemScale(qreal itemScale);
	// 设置预览窗口是否显示
	void setMinimapVisable(bool visabled);
	// 自适应缩放
	void autoFitSize();
signals:
	void sigViewScaleChanged();
	// 超出可视范围信号
    void sigOutOfView(bool visable);
protected:
	virtual void wheelEvent(QWheelEvent* event)override;
	virtual void resizeEvent(QResizeEvent* event)override;
	virtual void drawForeground(QPainter* painter, const QRectF& rect)override;
private:
	void updateMinimapPosition();
private:
	MinimapContainterWidget* m_minimapContainter = nullptr;
	bool m_originImageVisable = false;
	qreal m_oldItemScale = 1.0;
};
